#pragma once
#include <cstdint>
#include <functional>
#include <memory>
#include <string>

#include "result.hpp"

class MulticastAcceptor
{
public:
    using Callback = std::function<void(const std::vector<uint8_t>& data, const std::string& from_ip, uint16_t from_port)>;

    explicit MulticastAcceptor(const Callback& callback);
    ~MulticastAcceptor();

    cpp::Result<> init(uint16_t listen_port, const std::string& multicast_address,
                       const std::string& interface_address = "0.0.0.0") const;

    void run() const;

    cpp::Result<> release() const;

private:
    class Impl;
    std::unique_ptr<Impl> pimpl;
};
